package com.mingsoft.led.camera;

//摄像头{127.0.0.1{35500{username{password{0
public class CameraConfig {
	private String name = null;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public String getPort() {
		return port;
	}

	public void setPort(String port) {
		this.port = port;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getChannel() {
		return channel;
	}

	public void setChannel(String channel) {
		this.channel = channel;
	}

	private String ip = null;
	private String port = null;
	private String username = null;
	private String password = null;
	private String channel = null;

	public static CameraConfig parse(String str) {
		if (str == null) {
			return null;
		}
		String s[] = str.split("\\{");
		if (s.length < 6) {
			return null;
		}
		CameraConfig cc = new CameraConfig();
		cc.name = s[0];
		cc.ip = s[1];
		cc.port = s[2];
		cc.username = s[3];
		cc.password = s[4];
		cc.channel = s[5];
		return cc;
	}

	public String toString() {
		return name + "{" + toParamString();
	}

	public String toParamString() {
		return new StringBuilder().append(ip).append("{").append(port)
				.append("{").append(username).append("{").append(password)
				.append("{").append(channel).toString();
	}
}
